//
//  WeatherFirstView.m
//  weather
//
//  Created by 大L君的无敌战舰 on 16/4/12.
//  Copyright © 2016年 bigL.com. All rights reserved.
//

#import "WeatherFirstView.h"
#import "BLWeatherAnnounceView.h"
#import "BLButtonForWeatherFirstView.h"

@interface WeatherFirstView ()

/* 通告按钮 */
@property (strong, nonatomic) BLWeatherAnnounceView *announceView;

@end

@implementation WeatherFirstView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //加载子控件
        [self setChildView];
    }
    return self;
}


-(void)setChildView
{
    //详情按钮 - 今天
    BLButtonForWeatherFirstView * todayButton = [BLButtonForWeatherFirstView buttonWithType:UIButtonTypeCustom];
    [self addSubview:todayButton];
    //约束
    [todayButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(0);
        make.bottom.equalTo(self).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.5);
        make.height.mas_equalTo(64);
    }];
    
    
    //详情按钮 - 明天
    BLButtonForWeatherFirstView * tomorrowButton = [BLButtonForWeatherFirstView buttonWithType:UIButtonTypeCustom];
    [self addSubview:tomorrowButton];
    //约束
    [tomorrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(0);
        make.bottom.equalTo(self).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.5);
        make.height.mas_equalTo(64);
    }];
    
    
    
    //通告按钮
    BLWeatherAnnounceView *announceView = [[BLWeatherAnnounceView alloc]init];
    self.announceView = announceView;
    [self addSubview:announceView];
    //约束
    [announceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(0);
        make.bottom.equalTo(todayButton.mas_top).with.offset(-2);
        make.width.equalTo(self.mas_width).multipliedBy(0.5);
        make.height.equalTo(self.mas_height).multipliedBy(0.25);
    }];
    
////    !!!: 按钮调试颜色
//        announceView.backgroundColor   = BLRandomColor(2);
//        tomorrowButton.backgroundColor = BLRandomColor(2);
//        todayButton.backgroundColor    = BLRandomColor(2);
}

@end
